<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>
  <body>
    <!-- 案例小技巧  -->
    <!-- vue在渲染数据的时候 不会将null渲染到页面上 -->
    <div id="app">
      <button @click="add()">点击触发事件</button>
      <div>{{msg}}</div>
    </div>
  </body>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: null,
      },
      methods: {
        add() {
          this.msg = "触发点击事件";
        },
      },
    });
  </script>
</html>
